[HEADER]
	VERSION			00.00.00.00
	DESCRIPTION		Fast Transformation and Lighting Example
	COPYRIGHT		Imagination Technologies Ltd.
[/HEADER]

[TEXTURES]
	FILE base 	base.pvr		LINEAR-LINEAR-LINEAR
[/TEXTURES]

[VERTEXSHADER]
	NAME myVertShader
	[GLSL_CODE]
		attribute highp vec3	myVertex;
		attribute mediump vec3	myNormal;
		attribute mediump vec2	myUV;
		uniform mediump mat4	myMVPMatrix;
		uniform mediump mat3	myModelViewIT;
		const mediump vec3		myLightDirection = vec3(0.6,0.6,0.6);
		const mediump vec4		myMaterial = vec4(0.5,0.5,2.5,0.8);
		varying lowp float		DiffuseIntensity;
		varying lowp float		SpecularIntensity;
		varying lowp vec2		texCoordinate;
		void main(void)
		{
			// Transform the position into clipping-space.
			gl_Position = myMVPMatrix * vec4(myVertex,1);							
			mediump vec3 normal = normalize(myModelViewIT * myNormal);
			DiffuseIntensity = dot(normal, myLightDirection); 
			// Substract and multiply DiffuseIntensity by Specular Bias (w) and Scale (z) to have a 'decent' looking specular effect
			// See code below for an explanation of how these parameters are calculated
			SpecularIntensity = max((DiffuseIntensity - myMaterial.w) * myMaterial.z, 0.0); 
			// Pass the UV co-ordinates
			texCoordinate = myUV.st;
		}
	[/GLSL_CODE]
[/VERTEXSHADER]

[FRAGMENTSHADER]
	NAME myFragShader
	[GLSL_CODE]
		uniform sampler2D sampler2d;
		varying lowp float	DiffuseIntensity;
		varying lowp float	SpecularIntensity;
		varying lowp vec2	texCoordinate;
		void main (void)
		{
			lowp vec3 texColour  = vec3 (texture2D(sampler2d, texCoordinate));
			lowp vec3 finalColour = (texColour * DiffuseIntensity) + SpecularIntensity;
			gl_FragColor = vec4(finalColour, 1.0);
		}
	[/GLSL_CODE]
[/FRAGMENTSHADER]

[EFFECT]
	NAME myEffect

	ATTRIBUTE	myVertex			POSITION
	ATTRIBUTE	myNormal			NORMAL
	ATTRIBUTE	myUV				UV
	UNIFORM		myMVPMatrix			WORLDVIEWPROJECTION
	UNIFORM		myModelViewIT		WORLDVIEWIT
	UNIFORM		sampler2d			TEXTURE0

	TEXTURE 0 base

	VERTEXSHADER myVertShader
	FRAGMENTSHADER myFragShader
[/EFFECT]
